<!DOCTYPE html>
<!--
     SPDX-License-Identifier: CC-BY-SA-4.0
     SPDX-FileCopyrightText: 2020 seL4 Project a Series of LF Projects, LLC.
-->
<!-- Page last generated 2025-02-20 03:16:15 +0000 -->
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Raspberry Pi 4 Model B | seL4 docs</title>

    <!-- Our stylesheet and theme stylesheet.  Contains bootstrap. -->
    <link rel="stylesheet" href="/assets/css/style.css" type="text/css">
    <!-- Font awesome -->
    <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
    <!-- Pygments syntax highlighting  -->
    <link rel="stylesheet" href="/assets/css/highlighting/trac.css" type="text/css">
    <link rel="icon" type="image/x-icon" href="/assets/favicon.ico"><script defer data-domain="docs.sel4.systems"
	    src="https://analytics.sel4.systems/js/script.js"></script></head>

  <body class="container-fluid">

    



<header>
  <ul class="row menu">
    <li class="col-xs-12 col-md-2" >
            <a href="https://sel4.systems" class="skip-icon">
              <img class="img-responsive" src="/assets/logo-text-white.svg" alt="seL4 logo" />
            </a>
    </li>
    <li class="col-xs-12 col-md-10 menu">
      <nav aria-label="Banner links">
        <h2><a href="/Resources" />Resources</h2>
        <h2><a href="/processes" />Contributing</a></h2>
        <h2><a href="/projects" />Projects</h2>
        <h2><a href="/Tutorials" />Tutorials</h2>
        <iframe title="DuckDuckGo search bar" src="https://duckduckgo.com/search.html?site=docs.sel4.systems&prefill=Search%20sel4.systems" style="overflow:hidden;margin-bottom:10px; padding:0;height:40px;float:right;border-width: 0px"></iframe>
      </nav>
    </li>
  </ul>
  <div class="clear"></div>
  
<div class="breadcrumbs bootstrap hidden-sm-down">
  <nav class="sel-breadcrumb" aria-label="Breadcrumb" >
    <ol class=" list-unstyled" vocab="http://schema.org/" typeof="BreadcrumbList">
      
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/">
              <span property="name"><b>seL4 Docs</b></span>
            </a>
            <meta property="position" content="1" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/Hardware/">
              <span property="name"><b>Supported platforms</b></span>
            </a>
            <meta property="position" content="2" />
        </li>
      
        

        
          <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <span property="name">Raspberry Pi 4 Model B</span>
            <meta property="position" content="3" /></li>
          
    </ol>
  </nav>
  <nav class="sel-version" aria-label="Current Versions">
    <ol class="list-unstyled">
      <li class="list-unstyled text-right" style="margin-left:auto; padding:0rem 0rem;">
        Current versions:</li>
      <li class="list-unstyled text-right">
      <a href="/releases/sel4/13.0.0"><b>seL4-13.0.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/microkit/1.4.1"><b>microkit-1.4.1</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/camkes/camkes-3.11.0"><b>camkes-3.11.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/capdl/0.3.0"><b>capDL-0.3.0</b></a></li>
      </ol>
  </nav>
  <div class='clear'></div>
</div>


</header>

    <main>
      <div class="row">
  <div class="hidden-xs col-sm-4 col-md-3 col-lg-2">
    


<div class="sidebar">
















</div>

  </div>
  <div class="col-sm-8 col-md-9 col-lg-8 main">
    
    <div class="content">
      <h1 id="raspberry-pi-4-model-b">Raspberry Pi 4 Model B</h1>

<h2 id="serial-connection">Serial connection</h2>
<p>Serial TX and RX are located at GPIO pins 14 and 15 respectively.</p>

<h2 id="u-boot">U-Boot</h2>

<p>In order to build U-Boot for the Raspberry Pi 4B, run the following commands:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/u-boot/u-boot.git u-boot
<span class="nb">cd </span>u-boot
make <span class="nv">CROSS_COMPILE</span><span class="o">=</span>aarch64-linux-gnu- rpi_4_defconfig
make <span class="nv">CROSS_COMPILE</span><span class="o">=</span>aarch64-linux-gnu-
</code></pre></div></div>

<p>In the <code class="language-plaintext highlighter-rouge">u-boot</code> directory you should now see the U-Boot image <code class="language-plaintext highlighter-rouge">u-boot.bin</code> indicating that U-Boot has successfully compiled.</p>

<p>More information regarding U-Boot support for the Raspberry Pi can be found <a href="https://u-boot.readthedocs.io/en/latest/board/broadcom/raspberrypi.html">here</a>.</p>

<h2 id="sd-card-setup">SD card setup</h2>
<p>The RPi4 boots from the first FAT32 partition on the microSD card. Where files are specified,
they should be located in the root directory of this partition.</p>

<table>
  <thead>
    <tr>
      <th>Stage</th>
      <th>Filename</th>
      <th>Description</th>
      <th>Source</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>FSBL</td>
      <td>-</td>
      <td>Mounts SD and loads SSBL</td>
      <td>ROM</td>
    </tr>
    <tr>
      <td>GPU firmware</td>
      <td>start4.elf</td>
      <td>Loads CPU bootloader and boots CPU</td>
      <td><a href="https://github.com/raspberrypi/firmware/tree/master/boot/start4.elf">https://github.com/raspberrypi/firmware/tree/master/boot/start4.elf</a></td>
    </tr>
    <tr>
      <td>Additional GPU firmware</td>
      <td>fixup4.dat</td>
      <td>Fixes memory locations used in start4.elf</td>
      <td><a href="https://github.com/raspberrypi/firmware/tree/master/boot/fixup4.dat">https://github.com/raspberrypi/firmware/tree/master/boot/fixup4.dat</a></td>
    </tr>
    <tr>
      <td>Usually the Linux kernel, but could also be U-Boot</td>
      <td>u-boot.bin</td>
      <td>U-Boot binary</td>
      <td>Compiled using the instructions above</td>
    </tr>
    <tr>
      <td> </td>
      <td>config.txt</td>
      <td>U-Boot parameters</td>
      <td>Add <code class="language-plaintext highlighter-rouge">arm_64bit=1</code> and <code class="language-plaintext highlighter-rouge">kernel=u-boot.bin</code> to the bottom of <code class="language-plaintext highlighter-rouge">config.txt</code></td>
    </tr>
    <tr>
      <td> </td>
      <td>uboot.env</td>
      <td>U-Boot saved environment</td>
      <td>Generated by U-Boot (default environment) bootcmd copied to bootcmd_orig bootcmd and bootdelay removed. This file will not exist when you first setup your SD card.</td>
    </tr>
    <tr>
      <td> </td>
      <td>bcm2711-rpi-4-b.dtb</td>
      <td>RPi4 device tree blob</td>
      <td><a href="https://github.com/raspberrypi/firmware/tree/master/boot/bcm2711-rpi-4-b.dtb">https://github.com/raspberrypi/firmware/tree/master/boot/bcm2711-rpi-4-b.dtb</a></td>
    </tr>
    <tr>
      <td> </td>
      <td>overlays/*</td>
      <td>Device tree overlays</td>
      <td><a href="https://github.com/raspberrypi/firmware/tree/master/boot/overlays">https://github.com/raspberrypi/firmware/tree/master/boot/overlays</a></td>
    </tr>
  </tbody>
</table>

<h2 id="getting-sel4-onto-your-raspberry-pi-4">Getting seL4 onto your Raspberry Pi 4</h2>

<p>The final step to test that you have setup your RPi4 correctly is to build and run the
seL4test project.</p>

<p>You will see that the <code class="language-plaintext highlighter-rouge">init-build.sh</code> command contains the flag
<code class="language-plaintext highlighter-rouge">-DRPI4_MEMORY</code>, this specifies how much RAM exists on the Raspberry Pi that will run
the final seL4 image. Since seL4 needs to know the physical memory layout of the hardware
at build time, and the RPi4 has multiple models with different amounts of RAM, we have to
specify how much RAM the system will have when we build seL4. If <code class="language-plaintext highlighter-rouge">-DRPI4_MEMORY</code> is not supplied,
seL4 defaults to expecting 8GB of memory.</p>

<p>Checkout the sel4test project using repo as per <a href="/seL4Test">seL4Test</a></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>repo init <span class="nt">-u</span> https://github.com/seL4/sel4test-manifest.git
repo <span class="nb">sync
mkdir </span>cbuild
<span class="nb">cd </span>cbuild
../init-build.sh <span class="nt">-DPLATFORM</span><span class="o">=</span>rpi4 <span class="nt">-DAARCH64</span><span class="o">=</span>1 <span class="nt">-DRPI4_MEMORY</span><span class="o">=</span>&lt;1024,2048,4096,8192&gt;
<span class="c"># The default cmake wrapper sets up a default configuration for the target platform.</span>
<span class="c"># To change individual settings, run `ccmake` and change the configuration</span>
<span class="c"># parameters to suit your needs.</span>
ninja

</code></pre></div></div>

<p>Generated binaries can be found in the <code class="language-plaintext highlighter-rouge">images/</code> directory.</p>

<p>Now that we have a bootable image, we can run it on your RPi4. The following instructions describe
how to use a microSD card to boot seL4, using the seL4test image as well as the files mentioned
in the previous section.</p>

<p>The first step is to copy the seL4 image onto the microSD card to the root directory. After
removing the card from your computer and inserting into your RPi4, you can power on the RPi4.</p>

<p>Once the RPi4 boots up, you will see something like the following text from U-Boot:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Hit any key to stop autoboot:  2
</code></pre></div></div>

<p>At this point you want to interrupt the U-Boot booting process by pressing any key.</p>

<p>You will now be in the U-Boot command prompt, type the following command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fatls mmc 0
</code></pre></div></div>

<p>You should see the seL4test image you just placed on your microSD card.</p>

<p>From here, you can load and boot the image using:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>fatload mmc 0 0x10000000 sel4test-driver-image-arm-bcm2711
go 0x10000000
</code></pre></div></div>

    </div>
  </div>
</div>

    </main>
    


<footer class="site-footer">

  <h2 class="footer-heading">seL4 docs</h2>

  <div class="footer-col-wrapper">

    <div class="col-md-2">
      



<ul class="social-media-list">
  <li><a href="https://github.com/sel4"><i class="fab fa-github"></i> <span class="username">sel4</span></a></li><li><a href="https://github.com/sel4proj"><i class="fab fa-github"></i> <span class="username">sel4proj</span></a></li>
</ul>

    </div>

    <div class="col-md-8">
      <ul class="list-unstyled">
        <li>
          This site is for displaying seL4 related documentation.  Pull requests are welcome.
        </li>
        
          <li>
            Site last updated: Fri Feb 7 10:17:38 2025 +1100 ee78c8857c
          </li>
          <li>
                Page last updated: Tue Jan 14 15:56:06 2025 +1100 f28f1dfa66
          </li>
        
      </ul>
    </div>
    <div class="col-md-2">
<a href="https://github.com/seL4/docs/blob/master/Hardware/Rpi4.md">View page on GitHub</a>
      <br />
      <a href="https://github.com/seL4/docs/edit/master/Hardware/Rpi4.md">Edit page on GitHub</a>
      <br />
      <a href="/sitemap">Sitemap</a>
    </div>

  </div>

</footer>

  </body>
</html>
